{% macro render_comments(comments, current_user) %}
<div class="comments-section mt-4">
    <h3>评论</h3>
    {% if current_user.is_authenticated %}
    <div class="comment-form mb-4">
        <div class="form-group">
            <textarea class="form-control" rows="3" placeholder="写下你的评论..."></textarea>
        </div>
        <button class="btn btn-primary">发表评论</button>
    </div>
    {% endif %}
    
    <div class="comments-list">
        {% for comment in comments %}
        <div class="comment-item mb-3" data-comment-id="{{ comment.id }}">
            <div class="comment-header">
                <span class="comment-author">{{ comment.user.name }}</span>
                <small class="text-muted">{{ comment.created_at }}</small>
            </div>
            <div class="comment-content">
                {{ comment.content }}
            </div>
            {% if current_user.is_authenticated %}
            <div class="comment-actions">
                <a href="#" class="reply-btn">回复</a>
                {% if current_user.id == comment.user.id %}
                <a href="#" class="delete-btn text-danger">删除</a>
                {% endif %}
            </div>
            {% endif %}
            
            {% if comment.replies %}
            <div class="replies ml-4">
                {{ render_comments(comment.replies, current_user) }}
            </div>
            {% endif %}
        </div>
        {% endfor %}
    </div>
</div>
{% endmacro %}
